package Task14;

import com.sun.org.apache.bcel.internal.generic.SWITCH;

import java.util.Scanner;

/**
 * 牛客网计算日期到天数转换
 */

public class Main {
    public static void main(String[] args) {
        Scanner scanner  = new Scanner(System.in);
        while (scanner.hasNext()){
            String time = scanner.nextLine();
            String[] strings = time.split(" ");
            if(strings[0].length() > 4){
                return;
            }
            int mounth = Integer.parseInt(strings[1]);
            int date = Integer.parseInt(strings[2]);
            if(mounth > 12 || date > 31){
                return;
            }
            if(Integer.parseInt(strings[0]) % 4 == 0 &&Integer.parseInt(strings[0]) % 100 != 0 || Integer.parseInt(strings[0]) % 400 == 0){
                int[] arr = {31,29,31,30,31,30,31,31,30,31,30,31};
                int number = 0;
                for (int i = 0; i < mounth -1; i++) {
                    number += arr[i];
                }
                number += date;
                System.out.println(number);
            }else {
                int[] arr = {31,28,31,30,31,30,31,31,30,31,30,31};
                int number = 0;
                for (int i = 0; i < mounth -1; i++) {
                    number += arr[i];
                }
                number += date;
                System.out.println(number);
            }
        }
    }
}
